<?php
/*
+--------------------------------------------------------------------------
|	Move Backup Files to Rackspace Could Files
|   By Joshua Martinez
|   You are free to use this script any way you want.
|   http://www.joshuagmartinez.com
|   ========================================
|   Date: Friday, 10th September 2010
|	========================================
|	EXPECT AN ERROR ON THE REMOVE PART OF THE SCRIPT UNTIL YOU HAVE ENOUGH BACKED UP FILES TO BEGIN REMOVING THE OLD ONES
+--------------------------------------------------------------------------
*/
///////////////////////////////////////////////////////////////////////////////////
///THERE IS NO NEED TO EDIT THIS FILE
///////////////////////////////////////////////////////////////////////////////////

// INCLUDE THE VARIABLES
require('variables.inc.php');

// REMOVE YESTERDAYS BACKUP FILES
$remove = "rm -rf ".$SSPATH."/".$BACKUPDIR.""; 
system($remove); 

// RECREATE BACKUP FILE STORAGE LOCATION
mkdir ($SSPATH."/".$BACKUPDIR, 0777);

// BACKING UP DATABASE
echo "Starting database backup...";
$mysqlbackup = "mysqldump --host=".$DB_HOST." --user=".$DB_USER." --password=".$DB_PASSWORD." --all-databases | bzip2 > ".$SSPATH."/".$BACKUPDIR."/mysql-".$date.".bz2";
system($mysqlbackup);
echo "... database backup complete.";

// BACKING UP WP-CONTENT
echo "Starting wp-content backup...";
$wpbackup = "tar czf ".$SSPATH."/".$BACKUPDIR."/wp-content-".$date.".tgz ".$SSPATH."/wp-content";
system($wpbackup);
echo "... wp-content backup complete.";
?>